#!/usr/bin/python3
# encoding:utf-8

# 在 python 3.10.5 测试通过
# 导入引用的包文件
# pip install flask
# pip install flask_sock
# pip install flask-sockets
# pip install flask-cors 


from flask import Flask,url_for,redirect,render_template
from flask_sock import Sock
from flask_sockets import Sockets
from flask_cors import CORS   

import datetime
import base64
import time
import json
import flask

api = flask.Flask(__name__) 
# sockets = Sockets(api)

api.config['SOCK_SERVER_OPTIONS'] = {'ping_interval': 25}
sock = Sock(api)

# r'/*' 是通配符，让本服务器所有的 URL 都允许跨域请求
# CORS(api, resources=r'/*')

CORS(api, supports_credentials=True)   


# websocket 方式 
@sock.route('/deep')
def echo(ws):
    while True:
        message = ws.receive()
        print("server已收到消息:{}".format(message))  
        
        ren = {"data":[{"close":6,"count":0,"high":6,"id":1667750400,"low":6,"open":6,"quote_vol":0,"seq":1667750400000,"type":"candle.M5.btcusdt"},
        {"close":7.8,"count":5,"high":7.8,"id":1667836800,"low":7.1,"open":7.8,"quote_vol":5,"seq":1667836800000,"type":"candle.M5.btcusdt"},
        {"close":9,"count":6,"high":5.8,"id":1667923200,"low":7.2,"open":8.9,"quote_vol":5,"seq":1667923200000,"type":"candle.M5.btcusdt"},
        {"close":9.8,"count":7,"high":8.8,"id":1668268800,"low":5.2,"open":8.9,"quote_vol":5,"seq":1668268800000,"type":"candle.M5.btcusdt"},
        {"close":5.8,"count":8,"high":7.8,"id":1668355200,"low":7.2,"open":8.9,"quote_vol":5,"seq":1668355200000,"type":"candle.M5.btcusdt"},
        {"close":6.8,"count":9,"high":6.8,"id":1668441600,"low":7.2,"open":8.9,"quote_vol":5,"seq":1668441600000,"type":"candle.M5.btcusdt"}
        ],"type": "one"}
        ws.send(str(json.dumps(ren)))

@sock.route('/deep/deep')
def deep(ws):
    while True:
        message = ws.receive()
        print("server已收到消息:{}".format(message))  
        
        ren = {"area":[{"areaname":"CNY","areanameview":"CNY","data":[{"RiseAndFall":0,"billName":"102101A","billType":"0","coinCode":"102101A_CNY","coinSymbol":"","currentExchangPrice":"100.00","currentStatus":-2,"keepDecimalCoinCode":2,"lastExchangPrice":"200.00","maxPrice":"100","minPrice":"100","name":"102101A_CNY","openPrice":"100.00","points":"100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100","rmbPrice":"1","transactionSum":"9.00","usdt_maxPrice":0,"usdt_minPrice":0,"usdt_yesterdayPrice":0,"usdtcount":0,"usdttormb":6.8,"yesterdayPrice":"100.00"}]}],"buySellData":[{"idCur":1672987115,"idPrev":0,"msgType":"marketDetail0","symbolId":"221914_CNY","version":1,"_id":1672987115,"payload":{"asks":{"amount":[20,13,16,10,9,2,6,8,16],"level":[1,1,1,1,1,1,1,1,1]},"marketTrades":{"trades":[{"amount":1,"price":116,"tid":"T2301061500377140420","time":1672988437,"type":"sell"}]},"outerDisc":0,"poor":0,"priceAverage":0,"priceHigh":117,"priceLast":116,"priceLow":112,"priceNew":116,"priceOpen":115,"range":0,"symbolId":"btccny","totalAmount":28888,"totalVolume":403706,"trades":{"amount":[1,1,1,1,1,1,1,1,7,5,4,3,6,10,4,5,4,2,1,3,5,1,1,1,1,1,9,8,4,8],"direction":[1,1,1,2,2,1,2,2,1,1,2,2,2,2,2,1,2,1,1,1,2,1,2,2,2,2,1,1,2,1],"price":[116,114,114,114,115,116,115,115,115,114,114,112,112,113,114,114,114,115,115,115],"time":[1672988437,1672988428,1672988411,1672988403,1672988383,1672988353,1672988239,1672987938]},"turnVolume":0,"turnoverRate":0,"updownRatio":0,"updownVolume":0,"usdtCount":0,"usdtToRmb":6.8,"volumeRatio":0,"yestdayPriceLast":116,"symbolId":"221319_CNY","version":1,"_id":1672991122,"deep":{}}}],"deep":{"asks":[[123,16],[122,8],[121,6],[120,2]],"bids":[[114,1],[113,14],[112,7],[111.2,10],[111,13]]}}
        ws.send(str(json.dumps(ren)))

          

# -----------------------------------------  # -------------- # 接口定义 # ----- 
# 输出 templates 文件夹里的模版文件
@api.route('/test')
def page_ws_test_1():
    return render_template('test.html', title="websocket test")
    
# GET 方式访问
@api.route('/')
def hello_world():
    return 'Hello World!'
    
# post入参访问方式三：josn格式参数  
@api.route('/users',methods=['post'])
def users():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')
    
    # 传入参数示例    {'data':'数据内容'}
    data = flask.request.json.get('data')
  
    # 参数不能为空
    if  data:
        # 处理过程
        # ren 为传出的参数，json 格式
        ren = {'code': '200'  ,'msg':'接口调用成功' }
    else:
        ren = {'msg':'缺少必要的参数','code':1001 }
    
    # ren 为传出的参数，json 格式 
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/appConfig/listArticle',methods=['get'])
def aa():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "draw": "null",
              "page": 1,
              "pageSize": 10,
              "totalPage": 4,
              "recordsTotal": 31,
              "recordsFiltered": 31,
              "rows": [
                  {
                      "created": "2022-10-19T07:07:06.000+00:00",
                      "modified": "2022-10-19T07:07:06.000+00:00",
                      "id": 132,
                      "categoryId": 56,
                      "categoryName": "推荐要闻",
                      "title": "标题1",
                      "isShow": 1,
                      "seoTitle": "1",
                      "seoKeyword": "1",
                      "seoDescribe": "1",
                      "isStick": 0
                  },
                  {
                      "created": "2022-10-19T07:06:53.000+00:00",
                      "modified": "2022-10-19T07:06:53.000+00:00",
                      "id": 131,
                      "categoryId": 56,
                      "categoryName": "推荐要闻",
                      "title": "标题2",
                      "isShow": 1,
                      "seoTitle": "1",
                      "seoKeyword": "1",
                      "seoDescribe": "1",
                      "isStick": 0,
                      "isOutLink": 0
                  },
                  {
                      "created": "2022-10-19T07:06:42.000+00:00",
                      "modified": "2022-10-19T07:06:42.000+00:00",
                      "id": 130,
                      "categoryId": 56,
                      "categoryName": "推荐要闻",
                      "title": "标题3",
                      "isShow": 1,
                      "seoTitle": "1",
                      "seoKeyword": "1",
                      "seoDescribe": "1",
                      "isStick": 1,
                      "isOutLink": 0
                  },
                  {
                      "created": "2022-10-19T07:06:32.000+00:00",
                      "modified": "2022-10-19T07:06:32.000+00:00",
                      "id": 129,
                      "categoryId": 56,
                      "categoryName": "推荐要闻",
                      "title": "标题4",
                      "isShow": 1,
                      "seoTitle": "1",
                      "seoKeyword": "1",
                      "seoDescribe": "1",
                      "isStick": 0,
                      "isOutLink": 0
                  },
                  {
                      "created": "2022-10-19T07:06:24.000+00:00",
                      "modified": "2022-10-19T07:06:24.000+00:00",
                      "id": 128,
                      "categoryId": 56,
                      "categoryName": "推荐要闻",
                      "title": "标题5",
                      "isShow": 1,
                      "seoTitle": "1",
                      "seoKeyword": "1",
                      "seoDescribe": "1",
                      "isStick": 0,
                      "isOutLink": 0
                  },
                  {
                      "created": "2022-10-19T07:06:03.000+00:00",
                      "modified": "2022-10-19T07:06:03.000+00:00",
                      "id": 127,
                      "categoryId": 56,
                      "categoryName": "推荐要闻",
                      "title": "标题6",
                      "isShow": 1,
                      "seoTitle": "1",
                      "seoKeyword": "1",
                      "seoDescribe": "1",
                      "isStick": 1,
                      "isOutLink": 0
                  },
                  {
                      "created": "2022-10-19T07:06:02.000+00:00",
                      "modified": "2022-10-19T07:06:02.000+00:00",
                      "id": 126,
                      "categoryId": 56,
                      "categoryName": "推荐要闻",
                      "title": "标题7",
                      "isShow": 1,
                      "seoTitle": "1",
                      "seoKeyword": "1",
                      "seoDescribe": "1",
                      "isStick": 1,
                      "isOutLink": 0
                  },
                  {
                      "created": "2022-10-19T07:05:53.000+00:00",
                      "modified": "2022-10-19T07:05:53.000+00:00",
                      "id": 125,
                      "categoryId": 56,
                      "categoryName": "推荐要闻",
                      "title": "标题8",
                      "isShow": 1,
                      "seoTitle": "1",
                      "seoKeyword": "1",
                      "seoDescribe": "1",
                      "isStick": 1,
                      "isOutLink": 0
                  },
                  {
                      "created": "2022-10-19T07:05:44.000+00:00",
                      "modified": "2022-10-19T07:05:44.000+00:00",
                      "id": 124,
                      "categoryId": 56,
                      "categoryName": "推荐要闻",
                      "title": "标题9",
                      "isShow": 1,
                      "seoTitle": "1",
                      "seoKeyword": "1",
                      "seoDescribe": "1",
                      "isStick": 0,
                      "isOutLink": 0
                  },
                  {
                      "created": "2022-10-19T07:05:28.000+00:00",
                      "modified": "2022-10-19T07:05:28.000+00:00",
                      "id": 123,
                      "categoryId": 56,
                      "categoryName": "推荐要闻",
                      "title": "标题10",
                      "isShow": 1,
                      "seoTitle": "1",
                      "seoKeyword": "1",
                      "seoDescribe": "1",
                      "isStick": 1,
                      "isOutLink": 0
                  }
              ],
              "total": 31
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/klinevtwo/tradingview',methods=['get'])
def bb():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "firstIn": "true",
              "showCoin": "221914",
              "name": "匠想一号",
              "showFixPriceCoin": "CNY",
              "defaultCoin": "221914_CNY"
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/appConfig/getArticle',methods=['get'])
def cc():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "success": "true",
              "msg": "",
              "obj": {
                  "created": "2022-12-30T06:11:33.000+00:00",
                  "modified": "2022-12-30T06:16:12.000+00:00",
                  "id": 118,
                  "categoryId": 55,
                  "categoryName": "最新公告",
                  "title": "关于元旦节休假安排的通知",
                  "isShow": 1,
                  "seoTitle": "匠想科技",
                  "seoKeyword": "匠想科技",
                  "seoDescribe": "匠想科技",
                  "isStick": 1,
                  "writer": "匠想科技",
                  "source": "匠想科技",
                  "isOutLink": 0,
                  "logoImage": "",
                  "content": "",
                  "labelName": "newest"
              },
              "code": "",
              "total": 0
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/user/getUser',methods=['post'])
def dd():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "user": {
                  "created": "2022-11-01T10:01:30.000+00:00",
                  "modified": "2022-12-07T08:05:16.000+00:00",
                  "id": 100014,
                  "username": "xxx",
                  "password": "7A8AC1960E0CB3BBAF444E67D08AF279B1314D90C7D8F05D739C4804CEABEC7B",
                  "mobile": "19860200888",
                  "status": 1,
                  "salt": "272f195b440e4e1cb47f22172387dfc7",
                  "idCardFrontUrl": "",
                  "idCardBackUrl": "",
                  "nickname": "用户",
                  "headPortraitUrl": "file/c5dd43ac-7dea-4e86-b0b7-69a84ab6a7d4.png",
                  "sumReferralCode": 0,
                  "usedSumReferralCode": 0,
                  "isRealName": 1,
                  "integral": 0,
                  "isCheck": 0,
                  "nicknameState": 1,
                  "headPortraitUrlState": 1,
                  "regSource": 0,
                  "userType": 1,
                  "agentChannelCode": "b_yPew1oqO9w",
                  "huifuMemberId": "5fba4c494d1b407fb31a502f1f469b40",
                  "rechargeMemberId": "5fba4c494d1b407fb31a502f1f469b40",
                  "accountPassword": "1144ADB1545D8B8F29C4C587375DC067992E1D11030A7A8F3ED6BD0A6563F84F",
                  "tradeStatus": 1,
                  "referralCode": "AzPT0TRj1s",
                  "idcardNo": "440981********2230"
              }
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/subscribe/exwarehousereceipt/getByBillCode',methods=['post'])
def ff():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "success": "true",
              "msg": "查询成功",
              "obj": {
                  "created": "2022-11-09T06:51:52.000+00:00",
                  "modified": "2022-11-09T06:52:44.000+00:00",
                  "id": 72,
                  "enterpriseId": 50023,
                  "enterpriseName": "匠想科技",
                  "billName": "匠想一号",
                  "billCode": "221914",
                  "issuesNumber": 1000000,
                  "surplusNumber": 900000,
                  "issuesPrice": 100.00,
                  "details": "<p>测试</p>",
                  "status": 1,
                  "introduce": "<p>测试</p>",
                  "billType": 0,
                  "destroyCount": 0.0000
              },
              "code": "",
              "total": 0
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/fund/appfundaccount/getDetail',methods=['post'])
def ee():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "success": "true",
              "msg": "",
              "obj": {
                  "created": "2022-11-01T10:08:26.000+00:00",
                  "modified": "2022-12-27T06:57:51.000+00:00",
                  "id": 67,
                  "bsType": 0,
                  "customerId": 100014,
                  "hotMoney": 9998989.24,
                  "coldMoney": 0.07,
                  "accountNum": "13f9d895fc8341009f0de262481dd212",
                  "status": 0,
                  "fundName": "人民币",
                  "fundCode": "RMB",
                  "rechargeStatus": 0
              },
              "code": "",
              "total": 0
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/subscribe/exuserbillassets/possessCount',methods=['post'])
def rr():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "success": "true",
              "msg": "",
              "obj": {
                  "created": "2022-11-17T06:43:07.000+00:00",
                  "modified": "2022-11-17T06:43:07.000+00:00",
                  "id": 336,
                  "hotNumber": 0.0000,
                  "coldNumber": 0.0000,
                  "bsType": 0,
                  "customerId": 100014,
                  "wrId": 72,
                  "enterpriseId": 50023,
                  "enterpriseName": "匠想科技",
                  "billName": "匠想一号",
                  "billCode": "221914",
                  "issuesPrice": 100.00,
                  "status": 0
              },
              "code": "",
              "total": 0
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/entrust/getFeeRate',methods=['post'])
def qq():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "success": "true",
              "msg": "",
              "obj": {
                  "sellingFeeRatio": 0.3000000000,
                  "buyingFeeRatio": 0.3000000000
              },
              "code": "",
              "total": 0
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/entrust/user/rlist',methods=['post'])
def tt():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "success": "true",
              "msg": "",
              "obj": [
                  {
                                        "id": "null",
                                        "entrustNum": "WSc52b1ff31a49416083c750f48a192e6f",
                                        "inEntrustNum": "221216160424001476",
                                        "customerId": 100014,
                                        "accountId": 67,
                                        "coinAccountId": 284,
                                        "coinCode": "2221955",
                                        "fixPriceType": 0,
                                        "fixPriceCoinCode": "CNY",
                                        "type": 2,
                                        "status": 4,
                                        "entrustPrice": 5,
                                        "entrustCount": 1,
                                        "entrustSum": 5.00,
                                        "surplusEntrustCount": 1,
                                        "transactionSum": 0,
                                        "entrustTime": "2022-12-16T08:04:24.042+00:00",
                                        "entrustTime_long": 1671177864042,
                                        "transactionFeeRate": 0.3000000000,
                                        "transactionFee": 0,
                                        "floatUpPrice": 999999,
                                        "floatDownPrice": 0,
                                        "source": 3,
                                        "entrustWay": 1,
                                        "userName": "xxx",
                                        "trueName": "xxx",
                                        "surName": "xxx",
                                        "isOpenCoinFee": 0,
                                        "transactionFeePlat": 0,
                                        "isType": 0,
                                        "isTrigger": 3,
                                        "entrustPriceTrigger": 0,
                                        "functionType": 1,
                                        "triggerComparePrcie": 0
                                    },
                  {
                                        "id": "null",
                                        "entrustNum": "WSc52b1ff31a49416083c750f48a192e6f",
                                        "inEntrustNum": "221216160424001476",
                                        "customerId": 100014,
                                        "accountId": 67,
                                        "coinAccountId": 284,
                                        "coinCode": "2221955",
                                        "fixPriceType": 0,
                                        "fixPriceCoinCode": "CNY",
                                        "type": 2,
                                        "status": 4,
                                        "entrustPrice": 5,
                                        "entrustCount": 1,
                                        "entrustSum": 5.00,
                                        "surplusEntrustCount": 1,
                                        "transactionSum": 0,
                                        "entrustTime": "2022-12-16T08:04:24.042+00:00",
                                        "entrustTime_long": 1671177864042,
                                        "transactionFeeRate": 0.3000000000,
                                        "transactionFee": 0,
                                        "floatUpPrice": 999999,
                                        "floatDownPrice": 0,
                                        "source": 3,
                                        "entrustWay": 1,
                                        "userName": "xxx",
                                        "trueName": "xxx",
                                        "surName": "xxx",
                                        "isOpenCoinFee": 0,
                                        "transactionFeePlat": 0,
                                        "isType": 0,
                                        "isTrigger": 3,
                                        "entrustPriceTrigger": 0,
                                        "functionType": 1,
                                        "triggerComparePrcie": 0
                                    },
                  {
                      "id": "null",
                      "entrustNum": "WSc52b1ff31a49416083c750f48a192e6f",
                      "inEntrustNum": "221216160424001476",
                      "customerId": 100014,
                      "accountId": 67,
                      "coinAccountId": 284,
                      "coinCode": "2221955",
                      "fixPriceType": 0,
                      "fixPriceCoinCode": "CNY",
                      "type": 2,
                      "status": 4,
                      "entrustPrice": 5,
                      "entrustCount": 1,
                      "entrustSum": 5.00,
                      "surplusEntrustCount": 1,
                      "transactionSum": 0,
                      "entrustTime": "2022-12-16T08:04:24.042+00:00",
                      "entrustTime_long": 1671177864042,
                      "transactionFeeRate": 0.3000000000,
                      "transactionFee": 0,
                      "floatUpPrice": 999999,
                      "floatDownPrice": 0,
                      "source": 3,
                      "entrustWay": 1,
                      "userName": "xxx",
                      "trueName": "xxx",
                      "surName": "xxx",
                      "isOpenCoinFee": 0,
                      "transactionFeePlat": 0,
                      "isType": 0,
                      "isTrigger": 3,
                      "entrustPriceTrigger": 0,
                      "functionType": 1,
                      "triggerComparePrcie": 0
                  }
              ],
              "code": "2",
              "total": 0
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/fund/appfundaccount/list',methods=['post'])
def ii():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "draw": "",
              "page": 1,
              "pageSize": 6,
              "totalPage": 49,
              "recordsTotal": 290,
              "recordsFiltered": 290,
              "rows": [
                  {
                      "created": "2022-12-27T06:57:51.000+00:00",
                      "modified": "2022-12-27T06:57:51.000+00:00",
                      "id": 10423,
                      "bsType": 0,
                      "accountId": 67,
                      "accountType": 1,
                      "customerId": 100014,
                      "recordType": 1,
                      "transactionMoney": 0.01,
                      "balanceMoney": 9998989.24,
                      "transactionNum": "CZ221227145740263857867",
                      "status": 5,
                      "fundCode": "RMB",
                      "explainKey": "1",
                      "explainValue": "充值：可用+"
                  },
                  {
                      "created": "2022-12-27T06:43:55.000+00:00",
                      "modified": "2022-12-27T06:43:55.000+00:00",
                      "id": 10409,
                      "bsType": 0,
                      "accountId": 67,
                      "accountType": 1,
                      "customerId": 100014,
                      "recordType": 1,
                      "transactionMoney": 0.01,
                      "balanceMoney": 9998989.23,
                      "transactionNum": "CZ221227144335864471830",
                      "status": 5,
                      "fundCode": "RMB",
                      "explainKey": "1",
                      "explainValue": "充值：可用+"
                  }
              ],
              "total": 290
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/fund/appfundaccount/getWithdrawal',methods=['get'])
def pi():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "success": "true",
              "msg": "",
              "obj": "null",
              "code": "",
              "total": 0
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/bank/appcustomerbankcard/list',methods=['post'])
def pp():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "draw": "",
              "page": 1,
              "pageSize": 10,
              "totalPage": 1,
              "recordsTotal": 1,
              "recordsFiltered": 1,
              "rows": [
                  {
                      "created": "2022-12-07T08:11:11.000+00:00",
                      "modified": "2022-12-07T08:11:11.000+00:00",
                      "id": 73,
                      "customerId": 100014,
                      "mobile": "19860200888",
                      "userName": "xxx",
                      "cardName": "xxx",
                      "cardNumber": "6216631900001121577",
                      "reserveMobile": "19860200240",
                      "cardBank": "",
                      "cardCode": "01040000",
                      "status": 1,
                      "isDelete": 0,
                      "orderNo": "00221207161107451251066",
                      "protocolNo": "0421928128762240"
                  }
              ],
              "total": 1
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/fund/appuserzhifubao/list',methods=['post'])
def oo():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "draw": "",
              "page": 1,
              "pageSize": 10,
              "totalPage": 1,
              "recordsTotal": 1,
              "recordsFiltered": 1,
              "rows": [
                  {
                      "created": "2022-12-17T06:38:51.000+00:00",
                      "modified": "2022-12-17T06:38:51.000+00:00",
                      "id": 107,
                      "customerId": 100014,
                      "aliPayAccount": "19860200888",
                      "status": 0
                  }
              ],
              "total": 1
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/fund/appfundaccount/getRwConfig',methods=['post'])
def uu():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "success": "true",
              "msg": "",
              "obj": "{\"cashOutRate\":\"1\",\"rechargeTime\":\"30\",\"rechargeMultiple\":\"0.01\"}",
              "code": "",
              "total": 0
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/subscribe/exuserbillassets/list',methods=['post'])
def mm():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "draw": "",
              "page": 1,
              "pageSize": 20,
              "totalPage": 1,
              "recordsTotal": 4,
              "recordsFiltered": 4,
              "rows": [
                  {
                                        "created": "2022-11-07T01:25:28.000+00:00",
                                        "modified": "2022-11-28T09:48:08.000+00:00",
                                        "id": 283,
                                        "hotNumber": 1002.0000,
                                        "coldNumber": 5.0000,
                                        "bsType": 0,
                                        "customerId": 100014,
                                        "wrId": 49,
                                        "enterpriseId": 50020,
                                        "enterpriseName": "102701",
                                        "billName": "102701A",
                                        "billCode": "102701A",
                                        "issuesPrice": 100.00,
                                        "status": 0,
                                        "billType": 0,
                                        "username": "xxx",
                                        "mobile": "19860200888"
                                    },
                  {
                                        "created": "2022-11-07T01:25:28.000+00:00",
                                        "modified": "2022-11-28T09:48:08.000+00:00",
                                        "id": 283,
                                        "hotNumber": 1002.0000,
                                        "coldNumber": 5.0000,
                                        "bsType": 0,
                                        "customerId": 100014,
                                        "wrId": 49,
                                        "enterpriseId": 50020,
                                        "enterpriseName": "102701",
                                        "billName": "102701A",
                                        "billCode": "102701A",
                                        "issuesPrice": 100.00,
                                        "status": 0,
                                        "billType": 0,
                                        "username": "xxx",
                                        "mobile": "19860200888"
                                    },
                 {
                                       "created": "2022-11-07T01:25:28.000+00:00",
                                       "modified": "2022-11-28T09:48:08.000+00:00",
                                       "id": 283,
                                       "hotNumber": 1002.0000,
                                       "coldNumber": 5.0000,
                                       "bsType": 0,
                                       "customerId": 100014,
                                       "wrId": 49,
                                       "enterpriseId": 50020,
                                       "enterpriseName": "102701",
                                       "billName": "102701A",
                                       "billCode": "102701A",
                                       "issuesPrice": 100.00,
                                       "status": 0,
                                       "billType": 0,
                                       "username": "xxx",
                                       "mobile": "19860200888"
                                   },
                  {
                      "created": "2022-11-07T01:25:28.000+00:00",
                      "modified": "2022-11-28T09:48:08.000+00:00",
                      "id": 283,
                      "hotNumber": 1002.0000,
                      "coldNumber": 5.0000,
                      "bsType": 0,
                      "customerId": 100014,
                      "wrId": 49,
                      "enterpriseId": 50020,
                      "enterpriseName": "102701",
                      "billName": "102701A",
                      "billCode": "102701A",
                      "issuesPrice": 100.00,
                      "status": 0,
                      "billType": 0,
                      "username": "xxx",
                      "mobile": "19860200888"
                  }
              ],
              "total": 4
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/auth/logout',methods=['post'])
def op():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "success": "true",
              "msg": "",
              "obj": "",
              "code": "",
              "total": 0
          }
    return json.dumps(ren,ensure_ascii=False)

# post入参访问方式三：josn格式参数
@api.route('/auth/login',methods=['post'])
def opp():
    #前端传入的 from-data 格式参数
    # timestamp = flask.request.json.get('timestamp')
    # appid = flask.request.json.get('appid')
    # signature = flask.request.json.get('signature')

    # 传入参数示例    {'data':'数据内容'}
    # data = flask.request.json.get('data')

    # 参数不能为空
    # if  data:
        # 处理过程
        # ren 为传出的参数，json 格式

    # else:
        # ren = {'msg':'缺少必要的参数','code':1001 }

    # ren 为传出的参数，json 格式
    ren = {
              "success": "true",
              "msg": "",
              "obj": {
                  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIxOTg2MDIwMDI0MCIsInNvdXJjZSI6InBjIiwidHlwZSI6ImN1c3RvbWVyIiwiZXhwIjoxNjczNTIwMjY4LCJzaWduSWQiOiJlNDZjZjcyYmFhODk0NmQwODY3MTIxM2VkMThiMmQ3NyIsImlhdCI6MTY3MjkxNTQ2OH0.Ze9K6v-cQPh1HNs4uXFk17tO_4HS54MkFvgI_WR5kDQ"
              },
              "code": "",
              "total": 0
          }
    return json.dumps(ren,ensure_ascii=False)

# 启动 server 
if __name__ == "__main__": 
    # 启动 http 服务器 
    api.run(port=7070,debug=True,host='127.0.0.1') # 启动服务
    # debug=True,改了代码后，不用重启，它会自动重启
    # 'host='127.0.0.1' 别IP访问地址